<?php
/**
 * Session Class
 */

class WebSession{
	
	protected $autoStart = TRUE;
	
	public function __construct(){
	
		/**
		 * Session 配置
		 */
		ini_set('session.cache_expire',     180);
		#ini_set('session.cache_limiter',    'none');
		ini_set('session.cookie_lifetime',  3600);
		ini_set('session.gc_maxlifetime',   3600);
		ini_set('session.use_cookies',      1);
		ini_set('session.use_only_cookies', 1);
		ini_set('session.use_trans_sid',    0);
		
		if($this->autoStart){
			$this->open();
		}
		
		register_shutdown_function(array($this, 'close'));
	}
	
	public function open(){
	
//		session_set_save_handler($open, $close, $read, $write, $destroy, $gc)
		if(false){
			session_set_save_handler(array($this, 'sessOpen'), array($this, 'sessClose'), array($this, 'sessRead'), array($this, 'sessWrite'), array($this, 'sessDestroy'), array($this, 'sessGC'));
		}
		
		session_start();
	}
	
	public function close(){
	
	}
	
	public function getSavePath(){
		return session_save_path();
	}
}